{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('ad/index')}">商品列表</a></li>
            <li class="layui-this">添加商品</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('product/save')}" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" value="" required  lay-verify="required" placeholder="请输入商品名(必填)" class="layui-input">
                        </div>
                    </div>
                     <div class="layui-form-item">
                        <label class="layui-form-label">简介</label>
                        <div class="layui-input-block">
                            <input type="text" name="des" value="" placeholder="商品简介" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
						<label class="layui-form-label">图片</label>
						<div class="layui-input-block">
							<img id="thumb_" class="img-see" src="__IMG__/default_thumb.png" />
							<input type="text" name="thumb_img" readonly class="layui-input layui-input-inline">
							<input type="file" id="thumb_img" name="file" class="layui-upload-file">
						</div>
					</div>
					 <div class="layui-form-item">
                        <label class="layui-form-label">商品价格</label>
                        <div class="layui-input-block">
                            <input type="text" name="price"  required lay-verify="required" onkeyup="clearNoNums(this)"  style="width: 200px;" placeholder="兑换价格(必填)" class="layui-input">
                        </div>
                    </div>
                     <div class="layui-form-item">
                        <label class="layui-form-label">库存</label>
                        <div class="layui-input-block">
                            <input type="text" name="nums" required lay-verify="required" onkeyup="clearNoNums(this)"  style="width: 200px;" placeholder="请输入库存(必填)" class="layui-input">
                        </div>
                    </div>
                     <div class="layui-form-item">
                        <label class="layui-form-label">详细介绍</label>
                        <div class="layui-input-block">
                            <textarea name="content" required lay-verify="required" lay-verify="content" placeholder="" class="layui-textarea" id="content"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn"  lay-submit lay-filter="*">保存</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name='script'}
<script>
	function clearNoNums(obj)
	{
	   	obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
	   	obj.value = obj.value.replace(/^\./g,"");  //验证第一个字符是数字而不是.
	   	obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的.
	   	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");	   
	}
</script>
	
{/block}